-- @preview-file on clear

-- spine_loader.lua
-- Spine动画加载辅助模块

local SpineLoader = {}

function SpineLoader.preloadSpineConfig()
    local config = {
        atlasFile = "Demo_v0.0.8betaspine/model/que/que.atlas",
        skeletonFile = "Demo_v0.0.8betaspine/model/que/que.skel",
        imageFile = "Demo_v0.0.8betaspine/model/que/que.png",
        
        animations = {
            ["chi/chi-idle"] = {loop = true},
            ["chi/chi-walk"] = {loop = true},
            ["chi/chi-run"] = {loop = true},
            ["chi/chi-jump"] = {loop = false},
            ["chi/chi-fall"] = {loop = true},
            ["chi/chi-hurt"] = {loop = false},
            ["chi/chi-a1"] = {loop = false},
            ["chi/chi-a1toidle"] = {loop = false},
            ["chi/chi-a2"] = {loop = false},
            ["chi/chi-a2toidle"] = {loop = false},
            ["chi/chi-a3"] = {loop = false},
            ["chi/chi-a3toidle"] = {loop = false},
            ["chi/chi-a4"] = {loop = false},
            
            ["chui/chui-idle"] = {loop = true},
            ["chui/chui-walk"] = {loop = true},
            ["chui/chui-run"] = {loop = true},
            ["chui/chui-jump"] = {loop = false},
            ["chui/chui-fall"] = {loop = true},
            ["chui/chui-hurt"] = {loop = false},
            ["chui/chui-a1"] = {loop = false},
            ["chui/chui-a1toidle"] = {loop = false},
            ["chui/chui-a2"] = {loop = false},
            ["chui/chui-a2toidle"] = {loop = false},
            ["chui/chui-a3"] = {loop = false},
            
            ["zao/zao-idle"] = {loop = true},
            ["zao/zao-walk"] = {loop = true},
            ["zao/zao-run"] = {loop = true},
            ["zao/zao-jump"] = {loop = false},
            ["zao/zao-fall"] = {loop = true},
            ["zao/zao-hurt"] = {loop = false},
            ["zao/zao-a1"] = {loop = false},
            ["zao/zao-a1toidle"] = {loop = false},
            ["zao/zao-a2"] = {loop = false},
            
            -- 新增：通用翻滚动画（所有模式共用）
            ["fangun"] = {loop = false, duration = 0.6}
        }
    }
    
    return config
end

function SpineLoader.getAllAnimationNames()
    local config = SpineLoader.preloadSpineConfig()
    local names = {}
    
    for name, _ in pairs(config.animations) do
        table.insert(names, name)
    end
    
    table.sort(names)
    return names
end

function SpineLoader.animationExists(animationName)
    local config = SpineLoader.preloadSpineConfig()
    return config.animations[animationName] ~= nil
end

-- 新增：获取翻滚动画名称
function SpineLoader.getRollAnimation()
    return "fangun"
end

-- 新增：获取翻滚动画时长
function SpineLoader.getRollAnimationDuration()
    local config = SpineLoader.preloadSpineConfig()
    local rollAnim = config.animations["fangun"]
    return rollAnim and rollAnim.duration or 0.6
end

return SpineLoader